package com.overlord.im.connector.redis.register;

import com.overlord.im.connector.start.ConnectorRegister;
import org.springframework.data.redis.core.SetOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * All rights Reserved, Designed By www.szy.cn
 *
 * @author wuwei
 * @title RedisConnectorRegister
 * @package com.overlord.im.connector.redis.register
 * @date 2021-03-10 17:20
 * @Copyright 2014-现在 All rights reserved. 厦门神州鹰软件科技有限公司
 */
@Service
public class RedisConnectorRegister implements ConnectorRegister {

    private static final String CONNECTOR_REGISTER_KEY = "im:connector:addr";
    private static final String FIX_STR = ":";


    @Resource
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public void register(String ip, String port) {
        SetOperations<String, String> operations = stringRedisTemplate.opsForSet();
        operations.add(CONNECTOR_REGISTER_KEY, ip + FIX_STR + port);
    }
}
